package at.ac.tuwien.infosys.aic11.dto;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "internal_customer")
@XmlAccessorType(XmlAccessType.NONE)
public class InternalCustomer {
	
	@XmlAttribute(name="customer_id", required=true)
	private long customerId;
	
	@XmlElement(name="first_name", required=true)
	private String firstName;
	
	@XmlElement(name="middle_name", required=true)
	private String middleName;
	
	@XmlElement(name="last_name", required=true)
	private String lastName;
	
	@XmlElement(name="open_balance", required=true)
	private BigDecimal openBalance;
	
	@XmlElement(name="address", required=true)
	private Address address;

	@XmlElement(name="disbursement_preference", required=true)
	private DisbursementPreference disbursement;
	
	@XmlElement(name="rating", required=false)
	private Rating rating;
	
	@XmlElementWrapper(name = "credit_requests")
	@XmlElement(name = "credit_request", required=false)
	private List<Long> creditRequests = new ArrayList<Long>();
	
	
	public InternalCustomer() {}
	
	public InternalCustomer(long customerId, String firstName, String middleName, 
			String lastName, BigDecimal openBalance, Address address,
			DisbursementPreference distbursement){
		this.customerId=customerId;
		this.firstName=firstName;
		this.middleName=middleName;
		this.lastName=lastName;
		this.openBalance=openBalance;
		this.address=address;
		this.disbursement=distbursement;
	}
	
	public long getCustomerId() {
		return customerId;
	}
	public void setCustomerId(long customerId) {
		this.customerId = customerId;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getMiddleName() {
		return middleName;
	}
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public BigDecimal getOpenBalance() {
		return openBalance;
	}
	public void setOpenBalance(BigDecimal openBalance) {
		this.openBalance = openBalance;
	}	
	
	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public DisbursementPreference getDistbursement() {
		return disbursement;
	}

	public void setDistbursement(DisbursementPreference distbursement) {
		this.disbursement = distbursement;
	}

	public Rating getRating() {
		return rating;
	}

	public void setRating(Rating rating) {
		this.rating = rating;
	}

	public List<Long> getCreditRequests() {
		return creditRequests;
	}

	public void setCreditRequests(List<Long> creditRequests) {
		this.creditRequests = creditRequests;
	}
	
	public void addCreditRequest(Long c){
		this.creditRequests.add(c);
	}
	
	public String toString(){
		return "customerId: "+customerId+" firstname: "+firstName+" middleName: "+middleName+" lastName: "+lastName+" openBalance: "+openBalance.toString()+" address: "+address.toString();
	}
}
